package com.igeek.shop.web;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.igeek.shop.service.LinkageService;




public class LinkageServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;

	protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		request.setCharacterEncoding("utf-8");
		String state = request.getParameter("state");
		if(state.equals("init")) {
			initProvince(request,response);
		}else if(state.equals("city")) {
			initCity(request,response);
		}else if(state.equals("area")) {
			initArea(request,response);
		}
	}

	protected void initProvince(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		Object [] params = {0};
		LinkageService.getJson(params,response);
		
	}
	protected void initCity(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String pid = request.getParameter("pid");
		Object [] params = {pid};
		LinkageService.getJson(params,response);
		
	}
	protected void initArea(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String cid = request.getParameter("cid");
		Object [] params = {cid};
		LinkageService.getJson(params,response);
	}

}
